Add an integration test for the Network screen#9003
Conversation
| final client = io.HttpClient(); | ||
|
|
||
| final _dio = Dio(); |
There was a problem hiding this comment.
do any of these http clients need to be closed at some point?
There was a problem hiding this comment.
Hmm, I haven't seen a need to close them. Is there a point in the test lifecycle that I can? Like, in tearDown I could send a request to exit the process.
srawlins
left a comment
There was a problem hiding this comment.
Thanks for the feedback!
| final client = io.HttpClient(); | ||
|
|
||
| final _dio = Dio(); |
There was a problem hiding this comment.
Hmm, I haven't seen a need to close them. Is there a point in the test lifecycle that I can? Like, in tearDown I could send a request to exit the process.
Tear down would be a good place. I was wondering if we might see the test app process hang without closing these down. |
There's a lot to this change!
I wanted precise control over when the "test app" makes requests, and what kind, etc. I've added a capability for a Dart test app to print out what port it's "control server" is listening to, very similar to how it prints out the URL for DevTools to connect to.
The "control server" is a basic HTTP server, that can be controlled with very simple requests. In this case, when the server sees a request to '/get/', it calls a dart:io HttpClient to send an HTTP GET request. A request to '/post/' directs the HttpClient to send an HTTP POST request, etc.
For the network screen tests to see complete requests, there is a second HTTP server that responds to the test requests.
So some changes are made to TestDartCliApp to support the "control port". This int is then passed to the integration test in the 'test args' (see the changes to
integration_test/test_infra/run/run_test.dart).OK, then the test itself: This test is simple for now. The following types of requests are validated:
There are some TODOs for other requests we want to validate.
Work towards #7554.